<template>
  <div class="playlist-box">
    <transition name="playlist-mask">
      <div @click="$store.commit('audio/TOOGEL_PLAYLIST_STATE')" class="playlist-mask" v-if="playListState" />
    </transition>
    <transition name="playlist-wrapper">
      <div class="playlist-wrapper" v-if="playListState">
        <div :key="index" class="wrapper-audio-box" v-for="(audio, index) in playList">
          <div class="wrapper-audio">
            <el-image :src="audio.cover" class="audio-cover" fit="cover" />
            <div class="audio-info-wrapper">
              <div class="audio-info">
                <div class="item-t-s audio-name" v-if="audio.name">
                  <span :class="[{active: audio.name.length > 45}]">{{audio.name}}</span>
                </div>
              </div>
              <div class="audio-other">
                <div class="item-t-s audio-timer">{{audio.current}}</div>
                <div class="item-t-s audio-artist" v-if="audio.artist">
                  <span :class="[{active: audio.artist.length>20}]">{{audio.artist}}</span>
                </div>
              </div>
            </div>
          </div>
          <div class="wrapper-controller">
            <div :class="['item-t-s item-controller-btn item-prev iconfont', nowPlay.url===audio.url?'icon-ziyuanldpi6':'icon-ziyuanldpi11']" @click="$store.commit('audio/TOOGEL_NOW_PLAY',index)" />
            <div @click="$store.commit('audio/DELETE_PLAYLIST_ONECE', index)" class="item-t-s item-controller-btn item-prev iconfont icon-shanchu1" />
            <div class="item-t-s item-controller-btn item-prev iconfont icon-ziyuanldpi2" />
          </div>
        </div>
      </div>
    </transition>
  </div>
</template>

<script>
import { mapGetters } from 'vuex';

export default {
    computed: {
        ...mapGetters(['playListState', 'playList', 'nowPlay']),
    },
};
</script>

<style lang="less" scoped>
@import "~@/styles/animation.less";

.playlist-mask-enter,
.playlist-mask-leave-to {
  opacity: 0;
}

.playlist-mask-enter-to,
.playlist-mask-leave {
  opacity: 1;
}

.playlist-wrapper-enter,
.playlist-wrapper-leave-to {
  transform: translateX(100%);
}

.playlist-wrapper-enter-to,
.playlist-wrapper-leave {
  transform: translateX(0);
}

.playlist-box {
  position: relative;
  z-index: 7489436491;
}

.playlist-wrapper {
  width: 300px;
  height: calc(100% - @player-wrapper-height);
  position: fixed;
  top: 0;
  right: 0;
  transition: transform 0.3s;
  box-shadow: -1px -2px 3px @player-wrapper-background;
  user-select: none;
  overflow: auto;
  background-color: @player-wrapper-background;
  // background-color: @base_color;
  color: @player-wrapper-color;
}

.playlist-mask {
  width: 100%;
  height: calc(100% - @player-wrapper-height);
  position: fixed;
  top: 0;
  left: 0;
  transition: opacity 0.3s;
  background-color: rgba(0, 0, 0, 0.2);
}

.item-t-s:hover {
  text-shadow: 0 0 5px @player-wrapper-color;
}

.wrapper-audio-box {
  width: 300px;
  display: flex;
  justify-content: space-between;
  padding: 10px 5px;
  box-sizing: border-box;
  // border-bottom: 1px solid darken(@player-wrapper-background, 10%);
  border-bottom: 1px solid fade(@player-wrapper-color, 10%);
  font-size: 12px;

  .wrapper-audio {
    width: 100%;
    overflow: hidden;
    display: flex;
  }

  .audio-cover {
    width: 34px;
    height: 34px;
    flex: 0 0 auto;
    border-radius: 4px;
    margin-right: 10px;
  }

  .audio-info-wrapper {
    height: 34px;
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;

    .audio-info {
      display: flex;
      user-select: text;
      > div {
        // max-width: 110px;
        margin-right: 10px;
        white-space: nowrap;
        cursor: pointer;
        overflow: hidden;

        &:last-child {
          margin-right: 0;
        }

        > span.active {
          position: relative;
          animation: name-move 8s 0.5s infinite linear;
        }
      }
    }

    .audio-other {
      display: flex;
      transform-origin: bottom left;
      transform: scale(0.8);
      justify-content: flex-start;
      pointer-events: none;

      > div {
        margin-right: 5px;
      }
    }
  }
  position: relative;
  .wrapper-controller {
    position: absolute;
    right: 5px;
    bottom: 10px;
    display: flex;
    align-items: flex-end;
    flex: 0 0 auto;
    .item-controller-btn {
      margin: 0 5px;
      cursor: pointer;
    }
  }
}
</style>
